//
//  GAOVisitorController.swift
//  Weibo28
//
//  Created by 高辰 on 16/5/11.
//  Copyright © 2016年 itcast. All rights reserved.
//

import UIKit

class GAOVisitorController: UITableViewController {
    
    var loginMark = GAOUserAccountViewModel.UserAccountViewModel.isLogin
    //访客视图
    var visitorView: GAOVisitorView?
    
    override func loadView() {
        if loginMark == true {
            super.loadView()
        }else{
            visitorView = GAOVisitorView()
            visitorView?.visitorViewClosure = {
                self.oAuthAuthentication()
            }
            
            view = visitorView
            
            setupNavUI()
        }
    }
    
    
    override func viewDidLoad() {
        super.viewDidLoad()

    }
    
    private func setupNavUI() {
        navigationItem.leftBarButtonItem = UIBarButtonItem(title: "注册", fontSize: 15, target: self, action: "registerButtonAction")
        navigationItem.rightBarButtonItem = UIBarButtonItem(title: "登录", fontSize: 15, target: self, action: "loginButtonAction")
        
    }
    
    
    
    @objc private func registerButtonAction() {
        oAuthAuthentication()
    }
    
    @objc private func loginButtonAction() {
        oAuthAuthentication()
    }
    //OAuth 认证
    private func oAuthAuthentication() {
        let oAuthVC = GAOOAuthController()
        let nav = UINavigationController(rootViewController: oAuthVC)
        presentViewController(nav, animated: true, completion: nil)
        
    }
    
    
}



